// game level info,should resetting by user when choose game level
var g_gameLevel = 0;

JudgeGameState=function(){
    // emitter next group enemy
    if( EmptyEnemy() ){
        if( LevelFinish() ){
            cc.log("is play next level??");
            NextLevel();
        }else{
            cc.log("emitter next group");
            EmissionEnemy();
        }
    }
}
/////////////////  next level /////////////////
NextLevel=function(){
    // update level
    if(++g_gameLevel>=MaxLevel()){
        cc.log("all level end,resetting level to 0");
        g_gameLevel = 0;
        RemoveMainLayer(true);
    }else{
        RemoveMainLayer(true);
        AddMainLayer(g_mainScene);
    }
}


GetRandom=function(min,max) {
    var ranNum = Math.floor( min + (max - min+1) * Math.random() );
    return ranNum;
};

CreateJsonWithFile=function(filename){
    if(filename){
        cc.log("load json with file: "+filename);
        var jsonFile = null;
        if (cc.sys.isNative) {
            jsonFile = jsb.fileUtils.getStringFromFile(filename);
        }else {
            jsonFile = cc.loader._loadTxtSync(filename);
        }
        var jsonObj = JSON.parse(jsonFile);
        if(jsonObj){
            return jsonObj;
        }else{
            cc.log("parse json file: "+filename +" fail");
            return null;
        }
    }else{
        cc.log("error: "+filename+" json file name should not be null");
        return null;
    }
}